package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.enumclass.MerchantStoreStatus;
import com.rockcent.mall.lib.domain.enumclass.MerchantStoreType;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

/**
 * Created by DK on 16/10/9.
 */
@Entity
@Table(name = "merchant_store")
@DynamicInsert(value = true)
@DynamicUpdate(value = true)
public class MerchantStore extends IDEntityMall {


    /** 名称 */
    @Column(columnDefinition = "varchar(30) comment '名称'")
    private String name;

    /** 类型 */
    @Column(columnDefinition = "varchar(30) comment '类型 STORE(\"实体店\"), SHOP(\"网店\")'")
    @Enumerated(EnumType.STRING)
    private MerchantStoreType type;

    /** 地址 */
    @Column(columnDefinition = "varchar(255) comment '地址'")
    private String address;

    /** 网店(网址) */
    @Column(columnDefinition = "varchar(255) comment '网店(网址)'")
    private String site;

    /** 电话(手机/座机) */
    @Column(columnDefinition = "varchar(50) comment '电话(手机/座机)'")
    private String phone;

    /** 地区 */
    @Column(columnDefinition = "bigint(20) comment '地区ID'")
    private Long locationId;
    @Column(columnDefinition = "varchar(255) comment '地区文本'")
    private String locationStr;

    /** 状态 */
    @Column(columnDefinition = "varchar(30) comment '状态 ENABLE(\"启用\"), DISABLE(\"停用\")'")
    @Enumerated(EnumType.STRING)
    private MerchantStoreStatus status = MerchantStoreStatus.ENABLE;

    /** 门店编号(生成规则 001 - 999) */
    @Column(columnDefinition = "varchar(30) comment '门店编号(生成规则 001 - 999)'")
    private String number;

    /** 是否支持现有所有产品在此店兑换或自提 */
    @Column(columnDefinition = "varchar(20) comment '是否支持现有所有产品在此店兑换或自提(是:YES,否:NO)'")
    @Enumerated(EnumType.STRING)
    private Whether exchange = Whether.YES;

    public String getLocationStr() {
        return locationStr;
    }

    public void setLocationStr(String locationStr) {
        this.locationStr = locationStr;
    }

    /** 介绍 */
    @Column(columnDefinition = "varchar(255) comment '介绍'")
    private String introduction;

    @Column(columnDefinition = "bigint comment '商家 id'")
    private Long merchantId;

    @Column(columnDefinition = "bigint comment '平台 id'")
    private Long mallId;

    public static final String CHECK_NAME_IS_NOT_NULL = "商家门店名称 不能为空";
    public static final String CHECK_PHONE_IS_NOT_NULL = "商家门店电话 不能为空";
    public static final String CHECK_SITE_IS_NOT_NULL = "商家网店网址 不能为空";
    public static final String CHECK_ADDRESS_IS_NOT_NULL = "商家实体店地址 不能为空";
    public static final java.lang.String CHECK_TYPE_IS_NOT_NULL = "商家类型不能为空";
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public MerchantStoreType getType() {
        return type;
    }

    public void setType(MerchantStoreType type) {
        this.type = type;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Long getLocationId() {
        return locationId;
    }

    public void setLocationId(Long locationId) {
        this.locationId = locationId;
    }

    public MerchantStoreStatus getStatus() {
        return status;
    }

    public void setStatus(MerchantStoreStatus status) {
        this.status = status;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Whether getExchange() {
        return exchange;
    }

    public void setExchange(Whether exchange) {
        this.exchange = exchange;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    @Override
    public String toString() {
        return "MerchantStore{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", dateCreated=" + dateCreated +
                ", type=" + type +
                ", lastUpdated=" + lastUpdated +
                ", address='" + address + '\'' +
                ", isDelete=" + isDelete +
                ", site='" + site + '\'' +
                ", version=" + version +
                ", phone='" + phone + '\'' +
                ", locationId=" + locationId +
                ", locationStr='" + locationStr + '\'' +
                ", status=" + status +
                ", number='" + number + '\'' +
                ", exchange=" + exchange +
                ", introduction='" + introduction + '\'' +
                ", merchantId=" + merchantId +
                ", mallId=" + mallId +
                '}';
    }
}
